package com.example.bilibiliprojectspringboot.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: dedede
 * @Date: 2025/1/19 00:00
 * @Describe: 美化界面地址，http://ip:port/doc.html
 * 来自：https://doc.xiaominfo.com/docs/quick-start
 */

@Configuration
public class OpenAPIConfig {
  @Bean
  public OpenAPI customOpenApi() {
    return new OpenAPI()
        .info(new Info()
            .title("bilibili项目接口文档")
            .version("1.0")
            // 作者
            .contact(new Contact().name("dedede"))
            // 描述
            .description("bilibili项目 Api接口文档")
            // 服务条款网址-这里使用出处地址
            .termsOfService("http://doc.xiaominfo.com")
            // 许可证-这里使用出处信息
            .license(new License().name("Apache 2.0")
                .url("http://doc.xiaominfo.com")));
  }

  /**
   * Yml配置分组示例
   * springdoc:
   *   group-configs:
   *     - group: 'dzg-group1'
   *       paths-to-match: '/**'
   *       packages-to-scan: com.dzg.demo.controller.group1
   *     - group: 'dzg-group2'
   *       paths-to-match: '/**'
   *       packages-to-scan: com.dzg.demo.controller.group2
   * @return
   */
  @Bean
  public GroupedOpenApi dzgGroup1() {
    return GroupedOpenApi.builder()
        .packagesToScan("com.example.bilibiliprojectspringboot.controller")
        .group("group1")
        .pathsToMatch("/**")
        .build();
  }
}


